<?php
namespace app\servermenu\logic;

use \app\manage\logic\BaseLogic;

// 后台菜单的逻辑层
class AdminMenu extends BaseLogic
{
    // 根据角色获取后台菜单
    public function get(array $data): array
    {
    	// 根据token再取得角色
    	$sendDataRoles['query'] = json_encode([
            ['path' => 'serveruser/auth/Token/getRoles', 'param' => $data],
        ]);
        $sendDataRoles['success'] = '1';
    	$rolesRes = $this->sendDataOne(config('proxy_queue_url'), $sendDataRoles);
    	if (SUCCESS_STATUS !== $rolesRes['status']) {
    		return $rolesRes;
    	}
    	// 传给相应接口
    	$sendData['query'] = json_encode([
            ['path' => 'serveruser/menu/Menu/treeByRolesAndAppkey', 'param' => ['app_key'=>$data['app_key'], 'roles'=>$rolesRes['res']['autoRes']]],
        ]);
        $sendData['success'] = '1';
        $treeRes = $this->sendDataOne(config('proxy_queue_url'), $sendData);
        return auto_return($treeRes, '成功根据角色获取后台菜单', '根据角色获取后台菜单失败');
    }
}